package com.itmiaojie.dao;

import com.github.pagehelper.Page;
import com.itmiaojie.pojo.CheckGroup;
import com.itmiaojie.pojo.Setmeal;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface SetmealDao {
    void add(Setmeal setmeal);

    void setSetmealAndCheckGroup(Map<String, Integer> map);

    Page<Setmeal> selectByCondition(String queryString);


    Setmeal selectById(Integer id);

    @Select("  select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{id} ")
    List<Integer> findCheckItemIdsByCheckGroupId(Integer id);

    @Delete("delete from t_setmeal_checkgroup where setmeal_id = #{id}")
    void deleteAssociation(Integer id);

    void edit(Setmeal setmeal);

    List<Setmeal> findAll();

    /**
     * 进入详情页查询 多对多
     * @param id
     * @return
     */
    Setmeal findById(Integer id);
    @Select("SELECT  s.`name`,COUNT(o.`id`) AS value  FROM t_setmeal s,t_order o WHERE s.`id` = o.`setmeal_id` GROUP BY s.`name`")
    List<Map<String, Object>> findSetmealCount();
}
